package com.heima.utils.thread;

import com.heima.model.wemedia.pojos.WmUser;

/**
 * @Author: xrl
 * @Date: 2022/10/13  10:41
 * @Version 1.0
 * ThreadLocalUtil 工具类设置用户id到线程中
 */
public class WmThreadLocalUtil {
    private final static ThreadLocal<WmUser> WM_USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 添加到线程
     */
    public static void setUser(WmUser wmUser) {
        WM_USER_THREAD_LOCAL.set(wmUser);
    }


    /**
     * 从线程中获取
     */
    public static WmUser getUser() {
        return WM_USER_THREAD_LOCAL.get();
    }

    /**
     * 从线程中清理
     */
    public static  void  delete() {
        WM_USER_THREAD_LOCAL.remove();
    }
}
